package com.woniu.aimd.config.ai.chatclient;

import com.woniu.aimd.config.ai.tools.WebSearchTool;
import org.springframework.ai.chat.client.ChatClient;
import org.springframework.ai.chat.client.advisor.MessageChatMemoryAdvisor;
import org.springframework.ai.chat.client.advisor.SimpleLoggerAdvisor;
import org.springframework.ai.chat.memory.ChatMemory;
import org.springframework.ai.chat.memory.MessageWindowChatMemory;
import org.springframework.ai.openai.OpenAiChatModel;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class RightAiChatClientConfig {
    /**
     * 普通对话模型
     * @param model
     * @return
     */
    @Bean
    public ChatClient rightChatClient(OpenAiChatModel model,@Qualifier("redisChatMemory") ChatMemory chatMemory) {

        return ChatClient.builder(model).
                defaultAdvisors(
                        new SimpleLoggerAdvisor()
                        , MessageChatMemoryAdvisor.builder(chatMemory).build()).build();
    }

    @Bean
    public  ChatMemory messageMemory() {
        return MessageWindowChatMemory.builder().build();
    }
}
